package com.haiyou.common.util;

import com.google.common.collect.Lists;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author: xlight
 */
public class GameUtil {
    //------------------------------------------------------------字符串解析
    public static List<Integer> parseIntList(String str,String s){
        if(isBlank(str)){
            return Lists.newArrayList();
        }
        return Arrays.stream(str.split(s)).map(o -> Integer.parseInt(o)).collect(Collectors.toList());
    }

    public static int[] parseIntArray(String str, String s){
        return Arrays.stream(str.split(s)).mapToInt(Integer::parseInt).toArray();
    }

    //------------------------------------------------------------字符串工具
    public static int length(CharSequence cs) {
        return cs == null ? 0 : cs.length();
    }

    public static boolean isBlank(CharSequence cs) {
        int strLen = length(cs);
        if (strLen != 0) {
            for (int i = 0; i < strLen; ++i) {
                if (!Character.isWhitespace(cs.charAt(i))) {
                    return false;
                }
            }
        }
        return true;
    }

    public static boolean isNotBlank(CharSequence cs) {
        return !isBlank(cs);
    }

    //------------------------------------------------------------随机

    //------------------------------------------------------------http请求

}
